package com.hyjx.framework.component.excel.column;

import com.hyjx.framework.component.excel.template.ExcelTemplate;
import com.hyjx.framework.orm.dao.IBaseDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Excel模板列的服务实现类
 */
@Service(value = "excelTemplateColumnService")
@Transactional
public class ExcelTemplateColumnServiceImpl implements ExcelTemplateColumnService {
    @Resource
    private IBaseDao dao;
    
    private final String MODULE = "com.hyjx.framework.component.excel";

    @SuppressWarnings("unchecked")
    @Override
    public List<ExcelTemplateColumn> list(ExcelTemplateColumn dfc) {
        return this.dao.queryObjectList(MODULE + ".getDataFileConfig", dfc);
    }

    @Override
    public ExcelTemplate getExcelTemplate(String module_en_name) {

        return (ExcelTemplate) this.dao.queryObject(MODULE + ".getExcelTemplate", module_en_name);
    }


    @Override
    public void insert(ExcelTemplateColumn dfc) {
        this.dao.addObject(dfc.getModuleName() + ".insert", dfc);

    }

    @Override
    public void detele(ExcelTemplateColumn dfc) {

        this.dao.deleteObject(dfc.getModuleName() + ".delete", dfc);

    }

    @Override
    public String queryAll(ExcelTemplateColumn dfc) {

        //this.dao.queryObjectList(dfc.getModuleName() + ".select", dfc);
        //return CommonUtil.getJsonString(this.dao.queryObjectList(dfc.getModuleName() + ".select", dfc));
        return dao.getPageJsonStr(dfc.getModuleName() + ".select", dfc.getModuleName() + ".count", dfc);
    }

    @Override
    public void update(ExcelTemplateColumn dfc) {

        this.dao.updateObject(dfc.getModuleName() + ".update", dfc);
    }

    @Override
    public ExcelTemplateColumn queryById(ExcelTemplateColumn dfc) {

        return (ExcelTemplateColumn) this.dao.queryObject(dfc.getModuleName() + ".select", dfc);
    }
}